package asteroids.model.programs.expression;

import java.util.ArrayList;

import asteroids.model.programs.type.*;

public class DoubleExpression extends E{
	
	private DoubleType value;
	
	public DoubleExpression(int line, int column) {
		super(line, column);
		value = null;
	}
	
	public DoubleExpression(int line, int column, double d){
		this(line, column);
		value = new DoubleType(d);
	}
	
	@Override
	public DoubleType getValue(){
		return value;
	}

	public void setValue(T type){
		if(type instanceof DoubleType)
			value = (DoubleType) type;
	}

	/**
	 * Compares this expression to the given expression.
	 * If it is greater than 0, the given value is larger.
	 * If the result is 0, then they are equal.
	 * If the result is smaller than 0, then the value of this expression is greater.
	 * @return de.getValue() - this.getValue()
	 */
	public double compareTo(DoubleExpression de) {
		return ((DoubleType) de.getValue()).getValue() - ((DoubleType) this.getValue()).getValue();
	}

	@Override
	public void print(){
		getValue().print();
	}

	@Override
	public ArrayList<VariableExpression> getVariables() {
		return new ArrayList<VariableExpression>();
	}
	
	public String typecheck(){
		return "";
	}

}
